import { ref, onMounted, onUnmounted } from 'vue'

export function userMouse(){
    const x = ref(0)
    const y = ref(0)

    function update(e){
        // console.log(e.pageX, e.pageY)
        x.value = e.pageX;
        y.value = e.pageY;

        // console.log(x, y)
    }

    onMounted(()=>{
        window.addEventListener('mousemove', update)
    })
    onUnmounted(()=>{
        window.removeEventListener('mousemove', update)
    })

    // console.log(x.value,y.value)
    return { x, y }
}